﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;

namespace _引用类型测试
{
    class Program
    {
        static void Main(string[] args)
        {
            #region 测试代码

            //List<UserInfo> userInfos = new List<UserInfo>()
            //{
            //    new UserInfo(){Id = 1,UserType = 1,UserName = "张三",Sex = "男",CreateTime = DateTime.Now },
            //    new UserInfo(){Id = 1,UserType = 2,UserName = "筱空",Sex = "男",CreateTime = DateTime.Now },
            //    new UserInfo(){Id = 1,UserType = 3,UserName = "王五",Sex = "男",CreateTime = DateTime.Now },
            //    new UserInfo(){Id = 1,UserType = 2,UserName = "马六",Sex = "男",CreateTime = DateTime.Now },
            //    new UserInfo(){Id = 1,UserType = 1,UserName = "筱康",Sex = "男",CreateTime = DateTime.Now },
            //};

            //List<UserInfo> users = new List<UserInfo>();

            //List<string> remarks = new List<string>() { "这是备注信息一", "这是备注信息二" };

            //string json1 = JsonConvert.SerializeObject(userInfos);

            //userInfos.ForEach(x =>
            //{
            //    if (x.UserType == 2)
            //    {
            //        remarks.ForEach(r =>
            //        {
            //            x.Remark = r;
            //            UserInfo user = x.Clone() as UserInfo;
            //            users.Add(user);
            //        });
            //    }
            //    else
            //    {
            //        x.Remark = x.UserName + "," + x.Sex;
            //        UserInfo user = x.Clone() as UserInfo;
            //        users.Add(user);
            //    }
            //});


            //string json = JsonConvert.SerializeObject(users);

            #endregion

            List<Person> persons = new List<Person>();
            Person p = new Person() { Id = 1, Remark = "1", Msg = new Data() { Msg = "CCC" } };
            for (int i = 0; i < 10; i++)
            {
                Person person = (Person)p.Clone();
                person.Id = i;
                person.Remark = "Remark_" + i;
                Data d = new Data { Msg = "Msg_" + i };
                person.Msg = d;
                persons.Add(person);
            }

            string res = JsonConvert.SerializeObject(persons);


        }
    }
}
